package com.flymobi.mshop.activity;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Gallery;
import android.widget.TextView;

import com.flymobi.mshop.R;
import com.flymobi.mshop.adapter.MyGallery;
import com.flymobi.mshop.util.ShopCarVo;

/**
 * 
 * @author 余鹏
 */
public class ProdDetail extends Common {

	private Gallery gallery;
	private TextView title;
	private Button add;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.product_detail);
		iniView();
		setListener();
	}

	public void iniView() {
		gallery = (Gallery) findViewById(R.id.product_gallery);
		gallery.setAdapter(new MyGallery(this));
		gallery.setSelection(2);
		add = (Button) findViewById(R.id.product_cart_button);
		title = (TextView) findViewById(R.id.titleText);
		title.setText("尼康照相机");
	}

	public void setListener() {
		add.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				new AlertDialog.Builder(ProdDetail.this).setTitle("添加成功")
						.setMessage("商品已成功加入购物车").setPositiveButton("去购物车",
								new DialogInterface.OnClickListener() {

									@Override
									public void onClick(DialogInterface dialog,
											int which) {
									//	forwardRight(ShopCar.class);
										
										/*Main main =(Main) ProdDetail.this.getParent();
										main.getTabHost().setCurrentTab(2);*/
										forwardMain(2);
									}
								}).setNegativeButton("再逛逛",
								new DialogInterface.OnClickListener() {

									@Override
									public void onClick(DialogInterface dialog,
											int which) {
										
									}
								}).create().show();
				
			}
		});
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub

	}

	@Override
	public boolean onDown(MotionEvent e) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
			float velocityY) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void onLongPress(MotionEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
			float distanceY) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void onShowPress(MotionEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public boolean onSingleTapUp(MotionEvent e) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean onTouch(View v, MotionEvent event) {
		// TODO Auto-generated method stub
		return false;
	}
}